package com.fa4j.code.mate.repository;

import com.fa4j.code.mate.model.CodeMate;
import com.fa4j.code.mate.model.CodeMateProject;
import com.fa4j.code.mate.model.CodeMateProjectQuery;
import com.fa4j.code.mate.model.CodeMateType;
import com.fa4j.common.base.model.Page;
import com.fa4j.common.data.repository.BaseRepository;

import java.util.List;
import java.util.Optional;

/**
 * 代码元数据 持久化接口实现
 *
 * @since 2025-09-14 11:40:42
 */
public interface CodeMateRepository extends BaseRepository<CodeMate> {

    Optional<CodeMateProject> findProjectByProjectName(String projectName);

    Optional<CodeMate> findByTypeAndProjectName(CodeMateType type, String projectName);

    Optional<CodeMate> findByTypesAndModuleName(List<CodeMateType> types, String moduleName);

    Optional<CodeMate> findByTypesAndModuleCode(List<CodeMateType> types, Integer moduleCode);
    
    Optional<CodeMate> findByProjectNameAndTypeAndName(String projectName, CodeMateType type, String name);

    Optional<CodeMate> findByParentIdAndName(Integer parentId, String name);

    List<CodeMate> queryByParentId(Integer parentId);

    Page<CodeMateProject> queryProjectPage(CodeMateProjectQuery query);

    void modifyByModuleCode(Integer targetModuleCode, Integer sourceModuleCode, Long operatorId);

    void modifyByModuleName(String targetModuleName, String sourceModuleName, Long operatorId);

    void modifyByProjectName(String targetProjectName, String sourceProjectName, Long operatorId);


}
